var FindTarget = function(nums,target){
  let left = 0;
  let right = nums.length-1;
  while(left <= right){
    let mid = Math.floor(left + (right - left)/2);
    if(nums[mid] < target){
      left = mid + 1;
    }
    else if(nums[mid] > target){
      right = mid - 1;
    }
    else if(nums[mid] === target){
     left = mid;
     right = mid;
     while(left <= right){
       if(nums[left - 1] === target){
         left--;
       }
       else if(nums[right + 1] === target){
         right++;
       }else{
        return [left,right];
       }
       
   }
  }
}
  return [-1,-1];
}
console.log(FindTarget([5,7,7,8,8,8,10],8));